package cn.lingyueblog.roomManager.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.lingyueblog.roomManager.entity.BuildingsEntity;
import cn.lingyueblog.roomManager.service.BuildingsService;
import cn.lingyueblog.common.utils.PageUtils;
import cn.lingyueblog.common.utils.R;



/**
 * 
 *
 * @author zhenliu
 * @email 2368410997@qq.com
 * @date 2024-06-17 12:56:03
 */
@RestController
@RequestMapping("roomManager/buildings")
public class BuildingsController {
    @Autowired
    private BuildingsService buildingsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = buildingsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		BuildingsEntity buildings = buildingsService.getById(id);

        return R.ok().put("buildings", buildings);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BuildingsEntity buildings){
		buildingsService.save(buildings);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BuildingsEntity buildings){
		buildingsService.updateById(buildings);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		buildingsService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
